<h:panelGroup layout="block"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:c="http://java.sun.com/jstl/core" id="a1"
  xmlns:nxh="http://nuxeo.org/nxweb/html"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:s="http://jboss.org/schema/seam/taglib"
  class="dropzone"
  context="Clipboard_#{clipboardActions.currentSelectedListName}">

<c:if test="#{clipboardActions.initialized and not currentUser.anonymous}">

<h:form id="clipboardForm">
<s:cache key="#{clipboardActions.cacheKey}" enabled="false">

  <h:panelGroup id="ClipboardListView">

    <div class="userClipboard">

      <div class="tabsBar">
        <ul>
        <c:forEach var="docList" items="#{clipboardActions.descriptorsForAvailableLists}">
          <li class="#{nxu:test(clipboardActions.currentSelectedListName == docList.name, 'selected', '')}">
          <h:commandLink value="" action="#{clipboardActions.selectList}">
            <f:param name="listIdToSelect" value="#{docList.name}" />
            <h:outputText value="#{messages[docList.title]}" />
          </h:commandLink>
          </li>
        </c:forEach>
        </ul>
      </div>
      <div style="clear:both;"></div>

      <div class="userClipboardContent">

        <div id="clipboardCopy">

          <ul>
            <c:forEach var="copiedDocument"
              items="#{clipboardActions.currentSelectedList}">
              <li>
                <div class="positionR">
                  <span id="docClipboardRef:#{copiedDocument.ref}"
                    class="cell nxDraggable">
                    <nxu:graphicImage
                      value="#{nxd:iconPath(copiedDocument)}"
                      styleClass="icon smallIcon"
                      width="16px" height="16px" />
                  </span>
                  <c:choose>
                    <c:when test="#{clipboardActions.exists(copiedDocument.ref)}">
                      <nxd:restDocumentLink document="#{copiedDocument}" pattern="id">
                        <h:outputText value="#{nxd:titleOrId(copiedDocument)}" />
                      </nxd:restDocumentLink>
                    </c:when>
                    <c:otherwise>
                      <h:outputText value="#{nxd:titleOrId(copiedDocument)}" />
                    </c:otherwise>
                  </c:choose>
                  <span class="clipboardRemoveItem">
                    <h:commandLink
                      actionListener="#{clipboardActions.removeWorkListItem(copiedDocument.ref)}">
                      <nxu:graphicImage value="/icons/delete.png" />
                      <f:ajax execute="@this" render="ClipboardListView" />
                    </h:commandLink>
                  </span>
                </div>
              </li>
            </c:forEach>
          </ul>

          <c:if test="#{clipboardActions.workListEmpty}">
            <div class="emptyResult">
              <h:outputText
                value="#{messages['label.clipboard.empty']}"
                rendered="#{clipboardActions.workListEmpty}" />
            </div>
          </c:if>

        </div>

        <div class="clipboardFunctions">
          <nxu:dataList var="cb_action"
            value="#{clipboardActions.actionsForCurrentList}">
            <div class="clipboardFunction">
              <nxh:commandLink action="#{cb_action.getLink()}"
                onclick="#{cb_action.confirm}"
                immediate="#{cb_action.immediate}">
                <nxu:graphicImage value="#{cb_action.icon}"
                  rendered="#{not empty cb_action.icon}"
                  styleClass="icon smallIcon"
                  width="16px" height="16px" />
                <h:outputText value=" #{messages[cb_action.label]}" />
              </nxh:commandLink>
            </div>
          </nxu:dataList>
        </div>

      </div>

    </div>

  </h:panelGroup>

</s:cache>
</h:form>

<h:panelGroup id="ClipboardDroppable">
  <h:outputScript target="#{pageJsTarget}">
    <h:outputText
      value="jQuery('#clipboardCopy').droppable({ accept: '.cell', drop: function(event, ui) { copyElementIfIdNotStartsWith(ui.draggable.get(0), 'docClipboardRef'); }, hoverClass: 'dropIntoClipboardCopy' })" />
  </h:outputScript>
</h:panelGroup>

</c:if>

</h:panelGroup>
